package per.jdz.demo.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;


/**
 * @author Jdz
 * @date 2025/2/6
 */
@Component
@ConfigurationProperties(prefix = "file")
@Data
public class FilePathConfigProperty {

    private String originFileDir;
    private String originLandFileDir;
    private String splitDir;
    private String split;
    private String splitLand;
    @PostConstruct
    public void init() {
        String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        String yearMonth = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM"));
        this.originFileDir = originFileDir.replace("${yearMonth}", yearMonth).replace("${currentDate}", currentDate);
        this.originLandFileDir = originLandFileDir.replace("${yearMonth}", yearMonth).replace("${currentDate}", currentDate);
        this.split = this.originFileDir + this.splitDir;
        this.splitLand = this.originLandFileDir + this.splitDir;
    }
}
